package com.bcd.beans;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.bcd.model.ArticleType;
import com.bcd.model.AuctionType;

public class Book extends Article{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String _author;
	private String _publisher;
	private int _pages;
	private String _genre;	
	private int _year;
	
	@Override
	public void setArticle(ResultSet rs) {
		try {
			_user_id = rs.getInt("Users_user_id");
			_id = rs.getInt("article_id");
			_title = rs.getString("article_title");
			_start = rs.getDate("article_auction_start");
			_end = rs.getDate("article_auction_end");
			_price = rs.getFloat("article_auction_price");
			_auctionType = AuctionType.valueOf(rs.getString("article_auction"));			
			
			_genre = rs.getString("article_genre");
			_year = rs.getInt("article_year");
			
			_author = rs.getString("article_author");
			_publisher = rs.getString("article_publisher");
			_pages = rs.getInt("article_pagecount");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
	}
	@Override
	public String toString() {
		StringBuilder result = new StringBuilder();
	    String NEW_LINE = System.getProperty("line.separator");

	    result.append(this.getClass().getName() + " Object {" + NEW_LINE);
	    result.append(" Title: " + _title + NEW_LINE);
	    result.append(" Genre: " + _genre + NEW_LINE);
	    result.append("}");

	    return result.toString();
	}
	public Book(){
		super(ArticleType.BOOK);
	}
	
	/**
	 * @return the _author
	 */
	public String get_author() {
		return _author;
	}

	/**
	 * @param _author the _author to set
	 */
	public void set_author(String _author) {
		this._author = _author;
	}

	/**
	 * @return the _year
	 */
	public int get_year() {
		return _year;
	}

	/**
	 * @param _year the _year to set
	 */
	public void set_year(int _year) {
		this._year = _year;
	}

	/**
	 * @return the _publisher
	 */
	public String get_publisher() {
		return _publisher;
	}

	/**
	 * @param _publisher the _publisher to set
	 */
	public void set_publisher(String _publisher) {
		this._publisher = _publisher;
	}

	/**
	 * @return the _pages
	 */
	public int get_pages() {
		return _pages;
	}

	/**
	 * @param _pages the _pages to set
	 */
	public void set_pages(int _pages) {
		this._pages = _pages;
	}

	/**
	 * @return the genre
	 */
	public String get_genre() {
		return _genre;
	}

	/**
	 * @param genre the genre to set
	 */
	public void set_genre(String genre) {
		this._genre = genre;
	}
}
